package com.lzg.lishitehuanyuanze;

/**
 * @Author lizhigang Date: 2019/9/8 22:30
 * @description:
 */
public class LishitehuanTest {
    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle();

        rectangle.setWidth(20);

        rectangle.setHeight(10);

        resize(rectangle);

        //如果这时候把父类换成子类会怎么样？
        Square square = new Square();
        square.setLength(10);
        resize(square);

        //如果正方形与长方形都实现四边形接口那么 正方形执行会抱错，因为没有set方法，这就形成了继承约束，防止继承泛滥
    }

    public static void resize(Rectangle rectangle) {

        while (rectangle.getWidth() >= rectangle.getHeight()) {

            rectangle.setHeight(rectangle.getHeight() + 1);

            System.out.println("width:" + rectangle.getWidth() + ",height:" + rectangle.getHeight());

        }
        System.out.println("resize 方法结束" +

                "\nwidth:" + rectangle.getWidth() + ",height:" + rectangle.getHeight());

    }
}
